// pages/my/setting/index.js
const AJAX = require("../../../common/request")
const API = require("../../../common/api")
const common = require("../../../common/common")
const App = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navTop: 0,
    navContentHeight: 0,
    placeholderHeight: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.setData({
      navTop: App.globalData.navTop,
      navContentHeight: App.globalData.navContentHeight,
      options: JSON.stringify(options)
    })
    const query = wx.createSelectorQuery();
    query.select('.head').boundingClientRect();
    query.exec((res) => {
      this.setData({
        placeholderHeight: res[0].height
      })
    });

  },
  goUser() {
    wx.navigateTo({
      url: '/pages/my/user/index?method=update',
    })
  },
  updatewechatuser() {
    AJAX.POST('/system/AppWechat/updatewechatuser', {
      phone: '',
      status: 0
    })
    wx.showModal({
      title: '微信解绑',
      confirmText: "解绑",
      success: (res) => {
        console.log(res)
        if (res.confirm == true) {
          wx.setStorageSync('wxLoginUsername', '')
          wx.setStorageSync('wxLoginImg', '')
          wx.setStorageSync('wxLoginPhone', '')
          wx.setStorageSync('wxLoginStatus', false) // 登录状态
          App.globalData.user.wxLoginUsername = ""
          App.globalData.user.wxLoginStatus = false
          App.globalData.user.wxUserId =''
          App.globalData.user.wxLoginPhone = ''
          App.globalData.user.wxLoginImg = ''
          App.globalData.user.wxLoginOpenid = ''
          App.globalData.user.wechatUserId = ''
          console.log("解绑跳转")
          wx.reLaunch({
            url: '/pages/index/index',
          })
        }
      },
    })


  },

  goBack() {
    const pages = getCurrentPages();
    //获取不到上级返回首页
    if (pages.length > 1) {
      wx.navigateBack({})
    } else {
      wx.reLaunch({
        url: '/pages/index/index',
      })
    }
  },
  onShareAppMessage(options) {
    // 默认分享配置
    return {
      title: App.globalData.onShareAppMessage.title,
      path: App.globalData.onShareAppMessage.path,
      imageUrl: App.globalData.onShareAppMessage.imageUrl,
    }
  },


})